﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Configuration;

namespace WindowsFormsApplication3
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            string extPath = Application.ExecutablePath;
            Configuration config = ConfigurationManager.OpenExeConfiguration(extPath);
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            FormLogin frmLogin = new FormLogin();
            DialogResult dr = frmLogin.ShowDialog();
            if (dr == DialogResult.OK)
            {
                bool bSucceed = Convert.ToBoolean(System.AppDomain.CurrentDomain.GetData("Succeed"));
                if (bSucceed)
                {
                    Application.Run(new FormMain());
                }
                //(System.AppDomain.CurrentDomain.GetData("username") as TextBox).Text = "test";
                //if (frmLogin.GetUserName() == "admin" && frmLogin.Password == "admin")
                //{
                //    MessageBox.Show("恭喜你，登录成功！");
                //    if (frmLogin.IsUserSaving)
                //    {
                //        config.AppSettings.Settings.Add("user", frmLogin.UserName);
                //    }
                //    else
                //    {
                //        config.AppSettings.Settings.Remove("user");
                //    }
                //    config.Save(ConfigurationSaveMode.Modified);
                //}
                //else
                //{
                //    MessageBox.Show("恭喜你，登录失败，请与网管联系！");
                //    frmLogin.UserName = "";
                //    frmLogin.Password = "";
                //    frmLogin.SetFocus();
                //}

            }
        }
    }
}
